var NotificacaoS={
		"configsNotificacao":[],
		"getByIdGrupo":function(){
			rm.addRequest({
				"s" : "notificacao.business.ConfigNotificacaoBLL.getValidasByIdGrupo",
				//"s" : "ConfigNotificacaoBLL.getMenusByLoginUsuario",
				//"p" : loginusuario,
				"m":"notificacao",
				"puid":"login",
				"p" : login.idGrupo,
				"onLoad" : function(dtas) {					
					var htmlView = '';
					var regs =  dtas.rs;
					var tmL = regs.length;
					NotificacaoS.configsNotificacao = $.extend(regs,[]);
					for(var x =0;x<tmL;x++){
						var tipoN ="success";
						if(regs[x]["tpNotificacao"]==2){
							tipoN = "warning";
						}else if(regs[x]["tpNotificacao"]==3){
							tipoN = "danger";
						}
						htmlView += '<div class="divnotificao" style="display:none" id="notify_'+(x+1)+'">';
						htmlView += '<a href="#" onclick="NotificacaoS.showList.call(this)" alt="'+regs[x]["servicoList"]+'"><strong>'+regs[x]["descricao"]+'</strong></a>';
						htmlView += '<span class="badge pull-right alert-'+tipoN+'">0</span>';
						htmlView += '</br>'+regs[x]["mascara"];
						htmlView += '</div>';						
					}
					if(htmlView.length > 0){
						
						$("#hiddenThings").append('<div id="poppovthings">'+htmlView+'</div>');
						
						$('#sidebar').popover({html:true,placement:'bottom',title:'Mensagens',content:function(){
							return $("#poppovthings").html();
						},'animation':false,'container':'#sidebar','trigger':'manual'});//.popover('show');
					
						$('#noficacoesc').on('click',function(){
							var _thisx = $(this);
							if(_thisx.hasClass("showed")){
								_thisx.removeClass("showed");
								$('#sidebar').popover('hide');
							}else{
								_thisx.addClass("showed");
								$('#sidebar').popover('show');
							}							
						});	
						
						$("#noficacoesc").find(".badge").addClass("alert-warning");
						setTimeout(NotificacaoS.getList(), 3000);						
					}
					
					
				}
			});
		},
		"getList":function(){
			var tmL = this.configsNotificacao.length;
			var plogin = login.itlogin.getValue();
			var pidOrganizacao = login.idOrganizacao;
			var pidGrupo = login.idGrupo;
			var	pidUsuario = login.idUsuario;
			for(var y = 0;y < tmL;y++){
				
				  var tmpS = this.configsNotificacao[y]["servicoCount"];
				  var tmpM = 'none'; 
				  if(tmpS.match(/\.*?\./g).length > 1){
					  tmpS = tmpS.substring(tmpS.indexOf('.')+1,tmpS.length);
				   	  tmpM = this.configsNotificacao[y]["servicoCount"].substring(0,this.configsNotificacao[y]["servicoCount"].indexOf('.'));
				  }				
				rm.addRequest({
					"s" : tmpM+".business."+tmpS,
					"t"  : (y+1),
					"puid":"login",
					//"idRequest":(y+1),
					"idGrupo" : pidGrupo,
					"email":plogin,
					"idUsuario":pidUsuario,	
					"idOrganizacao":pidOrganizacao,
					"onLoad":function(dtasL) {
							//funcao chamada deve retornar um inteiro com o total do servico
							var totalRs = dtasL.rs;
							if(totalRs > 0){
								var eleM = $("#notify_"+dtasL.t);
								eleM.show().find("span.badge").html(totalRs);
								var notifyP = $("#noficacoesc").find(".badge").addClass("alert-sucess");
								notifyP.text((parseInt(notifyP.text())+1));	
							}
					}});
			}
	        login.show(false,false);
		}		
};
